<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	
	function __construct()
	{
		require_once BASEPATH.'nusoap/lib/nusoap.php';
	}
	
	public function index()
	{
		echo 'asasa';
		//$this->load->view('welcome_message');
	}
	
	public function wsdl()
	{
		// create a new soap server
		$namespace = "http://demo.dev/ci/welcome";
		
		$server = new soap_server();
		// configure our WSDL
		$server->configureWSDL("HelloExample");
		
		// set our namespace
		$server->wsdl->schemaTargetNamespace = $namespace;
		
		//Register a method that has parameters and return types
		$server->register(
		// method name:
				'HelloWorld',
				// parameter list:
				array('name'=>'xsd:string'),
				// return value(s):
				array('return'=>'xsd:string'),
				// namespace:
				$namespace,
				// soapaction: (use default)
				false,
				// style: rpc or document
				'rpc',
				// use: encoded or literal
				'encoded',
				// description: documentation for the method
				'Simple Hello World Method');
				
		//login
		$server->register(
		// method name:
				'login',
				// parameter list:
				array('strUserName'=>'xsd:string','strPassWord' => 'xsd:string'),
				// return value(s):
				array('return'=>'xsd:string'),
				// namespace:
				$namespace,
				// soapaction: (use default)
				false,
				// style: rpc or document
				'rpc',
				// use: encoded or literal
				'encoded',
				// description: documentation for the method
				'Login Method');
		//end login
		
		//Create a complex type
		$server->wsdl->addComplexType('MyComplexType','complexType','struct','all','',
				array( 'ID' => array('name' => 'ID','type' => 'xsd:int'),
						'YourName' => array('name' => 'YourName','type' => 'xsd:string')));
		
		//Register our method using the complex type
		$server->register(
		// method name:
				'HelloComplexWorld',
				// parameter list:
				array('name'=>'tns:MyComplexType'),
				// return value(s):
				array('return'=>'tns:MyComplexType'),
				// namespace:
				$namespace,
				// soapaction: (use default)
				false,
				// style: rpc or document
				'rpc',
				// use: encoded or literal
				'encoded',
				// description: documentation for the method
				'Complex Hello World Method');
		
		//Our Simple method
		function HelloWorld($name)
		{
			return "Hello " . $name;
		}
		
		//Our complex method
		function HelloComplexWorld($mycomplextype)
		{
			return $mycomplextype;
		}
		
		function returnArray($tmp = array())
		{
			return $tmp;
		}
		
		function login($username, $password){
			$arr = array();
			$intNumRows = 1;
			if($intNumRows==0)
			{
				$arr['StatusID'] = "0"; 
				$arr['MemberID'] = "0"; 
				$arr['Error'] = "Incorrect Username and Password";	
			}
			else
			{
				$arr['StatusID'] = "1"; 
				$arr['MemberID'] = "1"; 
				$arr['Error'] = "$username | $password";	
			}
			
			header('Content-type: application/json');
			return json_encode($arr);
		}
		
		// Get our posted data if the service is being consumed
		// otherwise leave this data blank.
		$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
		
		// pass our posted data (or nothing) to the soap service
		//$server->setClass('Welcome');
		//$server->handle();
		$server->service($POST_DATA);
		exit();
	}
	
	
	
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */